package com.glasses.controller;

import com.alibaba.fastjson.JSONObject;
import com.glasses.orm.base.Ex.BaseControllerEx;
import com.glasses.service.TicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * 优惠券 controller
 * Created by ashin on 2018/10/11.
 */
@Controller
@Scope("prototype")
@RequestMapping("/ticket")
public class TicketController extends BaseControllerEx {

    @Autowired
    TicketService ticketService;

    @Override
    protected void init() {
        super.init(ticketService);
    }

    @RequestMapping(value = "/doGenerate")
    public JSONObject doGenerate(@RequestParam Map map) throws Exception{
        return ticketService.generate(map);
    }

    /**
     * 获得兑换信息
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doGetTicket")
    public JSONObject doGetTicket(@RequestParam Map map) throws Exception{
        return ticketService.getTicket(map);
    }

    /**
     * 领取优惠券
     * @param map
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/doReceiveTicket")
    public JSONObject doReceiveTicket(@RequestParam Map map) throws Exception{
        return ticketService.receiveTicket(map);
    }
}
